Actually highlight the 'recently used' and 'search' items in the shortcuts bar
authorFederico Mena Quintero <federico@gnome.org>
Tue, 28 Jun 2011 22:24:53 +0000 (17:24 -0500)
committerFederico Mena Quintero <federico@gnome.org>
Sat, 2 Jul 2011 00:07:10 +0000 (19:07 -0500)
They weren't being selected in the shortcuts bar when those modes were
activated programmatically, instead of through the user selecting
them from the user interface.

gtk/gtkfilechooserdefault.c

index 1ea710260bbd40b09344e9afb9e62c2bef72d2dd..730875940a2e1948c4a871620a2e1a7656c54128 100644 (file)
@@ -8906,6 +8906,24 @@ stop_operation (GtkFileChooserDefault *impl, OperationMode mode)
     }
 }
 
+/* Sometimes we need to frob the selection in the shortcuts list manually */
+static void
+shortcuts_select_item_without_activating (GtkFileChooserDefault *impl, int pos)
+{
+  GtkTreeSelection *selection;
+  GtkTreePath *path;
+
+  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view));
+
+  g_signal_handlers_block_by_func (selection, G_CALLBACK (shortcuts_selection_changed_cb), impl);
+
+  path = gtk_tree_path_new_from_indices (pos, -1);
+  gtk_tree_selection_select_path (selection, path);
+  gtk_tree_path_free (path);
+
+  g_signal_handlers_unblock_by_func (selection, G_CALLBACK (shortcuts_selection_changed_cb), impl);
+}
+
 /* Main entry point to the searching functions; this gets called when the user
  * activates the Search shortcut.
  */
@@ -8923,6 +8941,8 @@ search_activate (GtkFileChooserDefault *impl)
   previous_mode = impl->operation_mode;
   impl->operation_mode = OPERATION_MODE_SEARCH;
 
+  shortcuts_select_item_without_activating (impl, shortcuts_get_index (impl, SHORTCUTS_SEARCH));
+
   stop_operation (impl, previous_mode);
 
   g_assert (impl->search_hbox == NULL);
@@ -9282,6 +9302,8 @@ recent_activate (GtkFileChooserDefault *impl)
   previous_mode = impl->operation_mode;
   impl->operation_mode = OPERATION_MODE_RECENT;
 
+  shortcuts_select_item_without_activating (impl, shortcuts_get_index (impl, SHORTCUTS_RECENT));
+
   stop_operation (impl, previous_mode);
 
   recent_hide_entry (impl);